﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLT_Public;
using System.Data;

namespace QLT_Data
{
    public class CTHoaDonBH_Data
    {
        KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
        public DataTable LayDuLieu()
        {
            return kn.LayDuLieu("Load_tbl_CTHoaDonBH");
        }
        public DataTable TaoBang(string sql)
        {
            return kn.taoBang(sql);
        }
        public int Insert_CTHoaDonBH(CTHoaDonBH_Public maHDBH, CTHoaDonBH_Public maThuoc,  CTHoaDonBH_Public soLuong, CTHoaDonBH_Public ngayBan,CTHoaDonBH_Public ghiChu)
        {
            int Nparameter = 5;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaHDBH";
            value[0] = maHDBH.MaHDBH;
            name[1] = "@MaThuoc";
            value[1] = maThuoc.MaThuoc;
            name[2] = "@SoLuong";
            value[2] = soLuong.SoLuong;
            name[3] = "@NgayBan";
            value[3] = ngayBan.NgayBan;
            name[4] = "@GhiChu";
            value[4] = ghiChu.GhiChu;
            return kn.update("insert_CTHoaDonBH", name, value, Nparameter);

        }
        public int Update_CTHoaDonBH(CTHoaDonBH_Public maHDBH, CTHoaDonBH_Public maThuoc, CTHoaDonBH_Public soLuong,CTHoaDonBH_Public ngayBan, CTHoaDonBH_Public ghiChu)
        {
            int Nparameter = 6;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaHDBH";
            value[0] = maHDBH.MaHDBH;
            name[1] = "@MaThuoc";
            value[1] = maThuoc.MaThuoc;
            name[2] = "@SoLuong";
            value[2] = soLuong.SoLuong;
            name[3] = "@NgayBan";
            value[3] = ngayBan.NgayBan;
            name[4] = "@GhiChu";
            value[4] = ghiChu.GhiChu;
            return kn.update("update_CTHoaDonBH", name, value, Nparameter);
        }
        public int Delete_CTHoaDonBH(CTHoaDonBH_Public maHDBH, CTHoaDonBH_Public maThuoc)
        {
            int Nparameter = 2;
            string[] name =new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaHDBH";
            value[0] = maHDBH.MaHDBH;
            name[1] = "@MaThuoc";
            value[1] = maThuoc.MaThuoc;
            return kn.update("delete_CTHoaDonBH", name, value, Nparameter);
        }
    }
}
